package com.waitingresult;

import cn.hutool.core.util.ObjUtil;
import lombok.AllArgsConstructor;
import lombok.Data;

import java.util.*;

public class Main {
    /**
     * int  stirng  // 字符串 最长 没有重复字符 子串的长度
     * // abcabc  6    abcdabc
     * map :  a,b,c,d   -> a -> b
     * count + 1 ;
     * <p>
     * <p>
     * fori
     * forj
     * string  = a
     * a
     * b
     * c
     * a
     * b
     * c
     *
     * @param args
     */
    public static void main(String[] args) {
        //extracted();
        Integer i= 999;
        Integer s =  Integer.valueOf(999);
        System.err.println( i == 999);
        System.err.println( i == s);

        User u1 = new User(9876);
        User u2 = new User(9876);
        System.err.println(u1.getId() == u2.getId());
        System.err.println(Runtime.getRuntime().availableProcessors());


    }
    @Data
    @AllArgsConstructor
    static class  User {
        private Integer id;
    }

    private static void extracted() {
        // 记录字符上一次出现的位置

        String s = "";


        int[] last = new int[s.length()];
        for (int i = 0; i < s.length(); i++) {
            last[i] = -1;
        }
        int n = s.length();

        int res = 0;
        int start = 0; // 窗口开始位置
        for (int i = 0; i < n; i++) {
            int index = s.charAt(i);
            start = Math.max(start, last[index] + 1);
            res = Math.max(res, i - start + 1);
            last[index] = i;
        }

        System.err.println(res);
    }

    private static void demo1() {
        // list "a" "a" "b" "b"
        // list<string> demo(list<string > list)
        ArrayList<String> strings = new ArrayList<>();
        strings.add("aa");
        strings.add("aa");
        strings.add("bb");
        strings.add("b");
        strings.add("c");
        List<String> count = count(strings);
        System.err.println();
    }

    public static List<String> count(List<String> list) {
        ArrayList<String> result = new ArrayList<>();

        HashMap<String, Integer> map = new HashMap<>();
        for (String str : list) {
            Integer integer = map.get(str);
            if (ObjUtil.isEmpty(integer)) {
                map.put(str, 1);
            } else {
                map.put(str, ++integer);
            }
        }
        // 得到 map中每一个str 的数量
        // a : 2, b:2,c:1
        Set<Map.Entry<String, Integer>> entries = map.entrySet();
        int num = 0;
        for (Map.Entry<String, Integer> entry : entries) {
            // String str = entry.getKey();
            Integer count = entry.getValue();
            //num 小于 当前count,
            num = num < count ? num : count;

        }
        for (Map.Entry<String, Integer> entry : entries) {
            String str = entry.getKey();
            Integer count = entry.getValue();
            if (num == count) {
                result.add(str);
            }
        }


        return result;
    }
}